<?php
/*
 * @Author: your name
 * @Date: 2020-12-22 15:01:53
 * @LastEditTime: 2020-12-22 15:08:22
 * @LastEditors: Please set LastEditors
 * @Description: 检测主机
 * @FilePath: /special/application/adminapiv3/service/module_manage/CheckHostService.php
 */
namespace app\adminapiv3\service\module_manage;

use app\adminapiv3\service\BaseService;
use app\common\exception\CustomException;
use think\Db;

class CheckHostService extends BaseService
{
    /**
     * @name: 检测主机是否在线
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-12-22 15:03:19
     */
    public function online (array $host_id_a)
    {
        $offline_host_id_a = Db::name('host_link')->whereIn('host_id', $host_id_a)->where('module', 'netfilter')->where('status', 0)->column('host_id');
        if(!empty($offline_host_id_a))
        {
            throw new CustomException($this->hostErrorMessage($offline_host_id_a, '已离线'), 422);
        }
    }
}